package com.um.jdy.ykc.command;

import com.um.jdy.ykc.utils.RadixsUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Data;

/**
 * 远程重启（运营平台->充电桩）
 *
 * @author 甘天伟
 * @since 2022/6/28
 * 版权所有 广州优匠科技有限公司
 */
@Data
public class Cmd92RebootDeviceRequest extends YkcCommand {

    /**
     * 桩编码：7个字节
     */
    private String code;

    /**
     * 当前时间：1个字节 0x01:立即执行 0x02:空闲执行
     */
    private int  type;


    public Cmd92RebootDeviceRequest(int serial,String code,int type) {
        super();

        this.serial = serial;
        this.encFlag = RadixsUtil.hexToInteger("00");
        this.command = RadixsUtil.hexToInteger("92");

        this.code = code;
        this.type = type;

        byte[] codeByte = RadixsUtil.hexToBytes(code);

        ByteBuf buff = Unpooled.buffer();
        buff.writeBytes(fillZeroBytes(codeByte,7 - codeByte.length));
        buff.writeByte(type);


        this.data = new byte[buff.readableBytes()];
        buff.readBytes(data);
        buff.release();

        postConstruct();
    }

}
